/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * VListadoIngrediente.java
 *
 * Created on 08/04/2011, 09:20:54 AM
 */

package vistas;

import controladores.CListadoIngrediente;
import java.util.Vector;
import javax.swing.JButton;
import modelos.MIngrediente;
import modelos.MTabla;



/**
* This code was edited or generated using CloudGarden's Jigloo
* SWT/Swing GUI Builder, which is free for non-commercial
* use. If Jigloo is being used commercially (ie, by a corporation,
* company or business for any purpose whatever) then you
* should purchase a license for each developer using Jigloo.
* Please visit www.cloudgarden.com for details.
* Use of Jigloo implies acceptance of these licensing terms.
* A COMMERCIAL LICENSE HAS NOT BEEN PURCHASED FOR
* THIS MACHINE, SO JIGLOO OR THIS CODE CANNOT BE USED
* LEGALLY FOR ANY CORPORATE OR COMMERCIAL PURPOSE.
*/
public class VListadoIngrediente extends javax.swing.JFrame {
    private Vector<JButton> botones;
    private CListadoIngrediente control;
    private MTabla modeloTabla;
    private Vector<String> fila;


    public VListadoIngrediente() {
        initComponents();
        modeloTabla= new MTabla();
        tblIngredientes.setModel(modeloTabla);

        fila= new Vector<String>();
        fila.add("Ingrediente");
        fila.add("Stock en Almacen");        
        modeloTabla.setColumnIdentifiers(fila);
        botones = new Vector<JButton>();
        botones.add(btnCancelar);
        botones.add(btnConsultar);
        botones.add(btnSalir);
        control = new  CListadoIngrediente(this);
        for (int i = 0; i < botones.size(); i++)
            botones.elementAt(i).addActionListener(control);
    }

    public void agregarFila(MIngrediente m){
        fila= new Vector<String>();
        fila.add(m.getDescripcion());
        fila.add(""+m.getStock());
        modeloTabla.addRow(fila);
    }

    public void  reiniciar() {
        modeloTabla.setRowCount(0);
    }

    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jScrollPane2 = new javax.swing.JScrollPane();
        tblIngredientes = new javax.swing.JTable();
        jPanel1 = new javax.swing.JPanel();
        btnConsultar = new javax.swing.JButton("Consultar");
        btnCancelar = new javax.swing.JButton("Cancelar");
        btnSalir = new javax.swing.JButton("Salir");
        jLabel4 = new javax.swing.JLabel();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle("Listado de Ingredientes");
        getContentPane().setLayout(null);

        tblIngredientes.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null}
            },
            new String [] {
                "Title 1", "Title 2", "Title 3", "Title 4"
            }
        ));
        jScrollPane2.setViewportView(tblIngredientes);

        getContentPane().add(jScrollPane2);
        jScrollPane2.setBounds(20, 70, 452, 340);
        jScrollPane2.setBackground(new java.awt.Color(255,255,255));

        jPanel1.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));
        jPanel1.setLayout(null);

        btnConsultar.setFont(new java.awt.Font("Ubuntu", 1, 15));
        btnConsultar.setText("Consultar");
        jPanel1.add(btnConsultar);
        btnConsultar.setBounds(20, 20, 120, 30);

        btnCancelar.setFont(new java.awt.Font("Ubuntu", 1, 15));
        btnCancelar.setText("Cancelar");
        jPanel1.add(btnCancelar);
        btnCancelar.setBounds(20, 60, 120, 30);

        btnSalir.setFont(new java.awt.Font("Ubuntu", 1, 15));
        btnSalir.setText("Salir");
        jPanel1.add(btnSalir);
        btnSalir.setBounds(20, 100, 120, 30);

        getContentPane().add(jPanel1);
        jPanel1.setBounds(170, 420, 160, 150);
        jPanel1.setBackground(new java.awt.Color(255,255,255));

        jLabel4.setFont(new java.awt.Font("Ubuntu", 1, 15));
        jLabel4.setText("Listado de Ingredientes");
        getContentPane().add(jLabel4);
        jLabel4.setBounds(160, 20, 190, 30);

        java.awt.Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
        this.setBounds(0, 0, 493, 605);
        getContentPane().setBackground(new java.awt.Color(14,151,255));
    }// </editor-fold>//GEN-END:initComponents

    /**
    * @param args the command line arguments
    */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new VListadoIngrediente().setVisible(true);
            }
        });
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton btnCancelar;
    private javax.swing.JButton btnConsultar;
    private javax.swing.JButton btnSalir;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JTable tblIngredientes;
    // End of variables declaration//GEN-END:variables

}
